package com.etbsms.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import com.etbsms.dao.IReportProblemDAO;
import com.etbsms.domain.ReportProblem;
import com.etbsms.service.IReportProblemService;
import com.etbsms.util.Constants;
import com.etbsms.util.Constants.REPORT_TYPE;


@Service
@Component("reportProblemService")
public class ReportProblemServiceImpl implements IReportProblemService {

	@Autowired
	private IReportProblemDAO reportProblemDAO;
	
	@Override
	public boolean save(ReportProblem entity) {
		// TODO Auto-generated method stub
		entity.setState(Constants.REPORT_STATE_NOTYET);
		entity.setProblem_date(new Date());
		return reportProblemDAO.save(entity);
	}

	@Override
	public boolean update(ReportProblem entity) {
		// TODO Auto-generated method stub
		entity.setState(Constants.REPORT_STATE_DONE);
		entity.setHandle_date(new Date());
		return reportProblemDAO.update(entity);
	}

	@Override
	public ReportProblem get(Integer seq_no) {
		// TODO Auto-generated method stub
		return reportProblemDAO.get(seq_no);
	}

	@Override
	public List<ReportProblem> getAll(REPORT_TYPE type) {
		// TODO Auto-generated method stub
		return reportProblemDAO.getAll(type);
	}
}
